home *** CD-ROM | disk | FTP | other *** search
-
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <time.h>
- #include <ctype.h>
-
- #include "lotto_calc_class.h"
-
-
- void lotto_calc::get_hot_pairs( void )
- {
- num_of_pairs = 0;
-
- for( int index1 = 1; index1 < 51; index1++ )
- {
- TEST_1 = index1;
- for( int index2 = (index1 + 1); index2 < 52; index2++ )
- {
- TEST_2 = index2;
- for( int index3 = 0; index3 < number_of_records; index3++ )
- {
- for( int index4 = 0; index4 < 6; index4++ )
- {
- if( record[index3]->set[index4] == TEST_1 )
- {
- for( int index5 = 0; index5 < 6; index5++ )
- {
- if( record[index3]->set[index5] == TEST_2 )
- {
- if( TEST_1 != TEST_2 )
- {
- thePair[num_of_pairs] = new a_pair;
- thePair[num_of_pairs]->PAIR_1 = 0;
- thePair[num_of_pairs]->PAIR_2 = 0;
- thePair[num_of_pairs]->pair_count = 0;
- if( (lotto_calc::record_pair( TEST_1, TEST_2, num_of_pairs )) == true )
- {
- num_of_pairs++;
- } else {
- delete( thePair[num_of_pairs] );
- }
- }
- }
- }
- }
- }
- }
- }
- }
- // insert
- lotto_calc::bubble_sort_pairs();
- lotto_calc::get_ten_best_pairs();
- return;
- }
-
-
- bool lotto_calc::record_pair( int one, int two, int count )
- {
- for( int index1 = 0; index1 < num_of_pairs; index1++ )
- {
- if( (index1 != count) && (index1 <= count) )
- {
- if( thePair[index1]->PAIR_1 == one )
- {
- if( thePair[index1]->PAIR_2 == two )
- {
- thePair[index1]->pair_count += 1; // keeps track of how many of the same pairs
- return false;
- }
- }
-
- if( thePair[index1]->PAIR_1 == two )
- {
- if( thePair[index1]->PAIR_2 == one )
- {
- thePair[index1]->pair_count += 1;
- return false;
- }
- }
- }
- }
- thePair[num_of_pairs]->PAIR_1 = one;
- thePair[num_of_pairs]->PAIR_2 = two;
- thePair[num_of_pairs]->pair_count += 1;
- thePair[num_of_pairs]->used = false;
- return true;
- }
-
- void lotto_calc::bubble_sort_pairs( void )
- {
- // puts structs in order of lowest count to highest
- // num_of_pairs will be the highest pair_count
- int size = 0;
- a_pair *hold = NULL;
-
- size = num_of_pairs;
-
- // swap the entire structs
- for( int pass = 1; pass <= (size - 1); pass++ )
- {
- for( int pass2 = 0; pass2 <= (size - 2); pass2++ )
- {
- if( thePair[pass2]->pair_count > thePair[pass2 + 1]->pair_count )
- {
- hold = thePair[pass2];
- thePair[pass2] = thePair[pass2 + 1];
- thePair[pass2 + 1] = hold;
- }
- }
- }
- return;
- }
-
- void lotto_calc::bubble_sort_sets( int count )
- {
- int hold1 = 0;
- int hold2 = 0;
- int size = 6;
-
- for( int index = 0; index <= count; index++ )
- {
- for( int pass = 1; pass <= (size - 1); pass++ )
- {
- for( int pass2 = 0; pass2 <= (size - 2); pass2++ )
- {
- if( array10[index]->set[pass2] > array10[index]->set[pass2 + 1] )
- {
- // swap the numbers and the protection for hot pairs
- hold1 = array10[index]->set[pass2];
- hold2 = array10[index]->protect[pass2];
- array10[index]->set[pass2] = array10[index]->set[pass2 + 1];
- array10[index]->protect[pass2] = array10[index]->protect[pass2 + 1];
- array10[index]->set[pass2 + 1] = hold1;
- array10[index]->protect[pass2 + 1] = hold2;
- }
- }
- }
- }
- return;
- }
-
- bool lotto_calc::verify_sets( int arrayNum )
- {
- for( int index = 0; index < arrayNum; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- for( int index3 = 0; index3 < 6; index3++ )
- {
- if( index2 != index3 )
- {
- if( array10[index]->set[index2] == array10[index]->set[index3] )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- array10[index]->set[index2] = (1 + rand() % 51);
- } else if( array10[index]->protect[index3] == 0 )
- {
- array10[index]->set[index3] = (1 + rand() % 51);
- } else {
- array10[index]->set[index2] = (1 + rand() % 51);
- }
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- void lotto_calc::get_ten_best_pairs( void )
- {
- int pair_num = 0;
- int limit = 0;
-
-
- // get the pairs that "sunk" to the bottom
- // choose from the twenty best pairs
- // from bubble_sort_pairs()
- // i.e. num_of_pairs is the greatest number of pairs
-
-
- for( int index = 0; index < 10; index++ )
- {
- limit++;
-
- if( limit > 2500 )
- {
- return;
- }
- do {
- pair_num = (1 + rand() % (num_of_pairs - 1));
- } while( (pair_num < (num_of_pairs - 26)) || (pair_num > (num_of_pairs - 1)) );
-
- if( thePair[pair_num]->used != true )
- {
- ten_hot_pairs[index][0] = thePair[pair_num]->PAIR_1;
- ten_hot_pairs[index][1] = thePair[pair_num]->PAIR_2;
- ten_hot_pairs[index][2] = 0;
- thePair[pair_num]->used = true; // make sure we don't pick it again
- } else {
- index--;
- }
- }
- return;
- }
-
- void lotto_calc::delete_pair_structs( void )
- {
- for( int index = 0; index <= (num_of_pairs - 1); index++ )
- {
- if( thePair[index] )
- {
- delete( thePair[index] );
- }
- }
- num_of_pairs = 0;
- return;
- }
-
- bool lotto_calc::get_zero_dists( void )
- {
- // get the zero distribution numbers from the last
- // 10 draws
- int zero_count = 0;
- for( int pass = 0; pass < 52; pass++ )
- {
- zeros[pass] = 1; // meaning zeros are "true"
- }
-
- if( number_of_records < 10 )
- {
- return false;
- }
-
- for( int index = 0; index < 10; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- for( int index3 = 1; index3 < 52; index3++ )
- {
- if( index3 == record[index]->set[index2] )
- {
- zeros[index3] = 0; // 0 indicates non-zero ( we have a match )
- }
- }
- }
- }
-
- return true;
- }
-
- int lotto_calc::pick_zero_dist( void )
- {
- int the_pick = 0;
-
- do {
- the_pick = (1 + rand() % 51);
- } while( zeros[the_pick] == 0 );
- return( the_pick );
- }
-
- bool lotto_calc::check_if_good_num( int the_guess, int count )
- {
- // checks against the first eight sets
- // ... the only sets that can have all different numbers
- // can only have eight with no repeats
- // returns false if it matches ... unless the match is protected (i.e. a hot pair)
- if( count > 8 )
- {
- count = 8;
- }
- for( int index = 0; index < (count - 1); index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( (array10[index]->set[index2] == the_guess) && (array10[index]->protect == 0) )
- {
- return false;
- }
- }
- }
- return true;
- }
-
- bool lotto_calc::check_if_good_set( int arrayNum, int setNum )
- {
- // checks the set against itself
- for( int index = 0; index < 6; index++ )
- {
- if( index != setNum )
- {
- if( array10[arrayNum]->set[setNum] == array10[arrayNum]->set[index] )
- {
- return false; // means we have a match
- }
- }
- }
- return true; // means no match i.e. a good number
- }
-
-
-
-
- bool lotto_calc::make_numbers( int user_request )
- {
- time_t *cur_time = NULL;
- srand( time(cur_time) );
-
- last_hot_pair = NULL;
-
- int set_count = 0;
- bool tester = NULL;
- int loop_counter = 0;
- int a_guess = 0;
- int been_here_done_that = 0;
- int limit = 0;
- int counter = 0;
- bool badone = false;
-
- bool user_wants = false;
-
- if( user_request > 0 )
- {
- user_wants = true;
- }
-
- if( lotto_calc::read_file() == false )
- {
- return false;
- }
-
-
- if( (lotto_calc::get_zero_dists()) == false )
- {
- return false;
- }
-
- lotto_calc::get_hot_pairs();
-
- // init the array
- if( user_wants == false )
- {
- for( int index = 0; index < MAX_GEN; index++ )
- {
- array10[index] = new calc_array;
- lotto_calc::clear_array10( index );
- }
- }
-
- if( user_wants == true )
- {
- for( int index2 = 0; index2 < user_wants; user_wants++ )
- {
- array10[index2] = new calc_array;
- lotto_calc::clear_array10( index2 );
- }
- }
-
-
- do {
-
- begin: // yeah, ok, its a goto, so sue me!!
-
- if( set_count == 0 )
- {
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- }
-
- lotto_calc::clear_array10( set_count );
-
- if( (lotto_calc::get_a_hot_pair( set_count )) == false )
- {
- array10[set_count]->set[0] = (1 + rand() % 51);
- array10[set_count]->set[1] = (1 + rand() % 51);
- }
-
- loop_counter = 0;
-
- do {
- array10[set_count]->set[2] = pick_zero_dist();
-
- if( set_count < 8 )
- {
- tester = lotto_calc::check_if_good_num( array10[set_count]->set[2], set_count );
- } else {
- tester = true;
- }
- loop_counter++;
- } while( (tester == false) && (loop_counter <= 1000) );
-
- if(tester == true )
- {
- array10[set_count]->protect[2] = 1;
- }
- if( tester == false )
- {
- array10[set_count]->set[2] = (1 + rand() % 51);
- array10[set_count]->protect[2] = 0;
- }
-
- for( int loop = 0; loop < 3; loop++ )
- {
- a_guess = NULL;
-
- switch( (a_guess = (1 + rand() % 5)) )
- {
- case 1:
- {
- while( (lotto_calc::is_odd( (array10[set_count]->set[loop + 3]
- = (1 + rand() % 51))) ) == false ){;}
- break;
- }
- case 2:
- {
- while( (lotto_calc::is_white( (array10[set_count]->set[loop + 3]
- = (1 + rand() % 51))) ) == false ){;}
- break;
- }
- case 3:
- {
- if( (lotto_calc::is_blue( (array10[set_count]->set[loop + 3]
- = (1 + rand() % 51))) ) == false ){;}
- break;
- }
- case 4:
- {
- while( (lotto_calc::is_red( (array10[set_count]->set[loop + 3]
- = (1 + rand() % 51))) ) == false ){;}
- break;
- }
- case 5:
- {
- while( (lotto_calc::is_even( (array10[set_count]->set[loop + 3]
- = (1 + rand() % 51))) ) == false ){;}
- break;
- }
- }
- }
-
- for( int index = 0; index < set_count; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( lotto_calc::check_if_good_num( (array10[index]->set[index2]), set_count ) == false )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- array10[index]->set[index2] = (1 + rand() % 51);
- index--;
- }
- }
- }
- }
-
- if( set_count < 8 )
- {
- limit = 5000;
- } else {
- limit = 250;
- }
-
- while( (lotto_calc::check_if_valid_sets( set_count ) == false) && (counter <= limit) )
- {
- counter++;
- }
- counter = 0;
-
- while( lotto_calc::verify_sets( set_count ) == false ){;}
-
- for( int index = 0; index < 6; index++ )
- {
- if( (lotto_calc::check_if_good_set( set_count, index )) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- goto begin;
- }
- }
-
- badone = false;
- if( set_count == 7 && been_here_done_that < 250 )
- {
- been_here_done_that++;
-
- // check set 0 against itself
- if( array10[0]->set[0] == 0 ){badone = true;}
- if( array10[0]->set[0] == array10[0]->set[1] ){badone = true;}
- if( array10[0]->set[0] == array10[0]->set[2] ){badone = true;}
- if( array10[0]->set[0] == array10[0]->set[3] ){badone = true;}
- if( array10[0]->set[0] == array10[0]->set[4] ){badone = true;}
- if( array10[0]->set[0] == array10[0]->set[5] ){badone = true;}
-
- // check set 1 against itself
- if( array10[1]->set[0] == 0 ){badone = true;}
- if( array10[1]->set[0] == array10[1]->set[1] ){badone = true;}
- if( array10[1]->set[0] == array10[1]->set[2] ){badone = true;}
- if( array10[1]->set[0] == array10[1]->set[3] ){badone = true;}
- if( array10[1]->set[0] == array10[1]->set[4] ){badone = true;}
- if( array10[1]->set[0] == array10[1]->set[5] ){badone = true;}
-
- // check set 2 against itself
- if( array10[2]->set[0] == 0 ){badone = true;}
- if( array10[2]->set[0] == array10[2]->set[1] ){badone = true;}
- if( array10[2]->set[0] == array10[2]->set[2] ){badone = true;}
- if( array10[2]->set[0] == array10[2]->set[3] ){badone = true;}
- if( array10[2]->set[0] == array10[2]->set[4] ){badone = true;}
- if( array10[2]->set[0] == array10[2]->set[5] ){badone = true;}
-
- // check set 3 against itself
- if( array10[3]->set[0] == 0 ){badone = true;}
- if( array10[3]->set[0] == array10[3]->set[1] ){badone = true;}
- if( array10[3]->set[0] == array10[3]->set[2] ){badone = true;}
- if( array10[3]->set[0] == array10[3]->set[3] ){badone = true;}
- if( array10[3]->set[0] == array10[3]->set[4] ){badone = true;}
- if( array10[3]->set[0] == array10[3]->set[5] ){badone = true;}
-
- // check set 4 against itself
- if( array10[4]->set[0] == 0 ){badone = true;}
- if( array10[4]->set[0] == array10[4]->set[1] ){badone = true;}
- if( array10[4]->set[0] == array10[4]->set[2] ){badone = true;}
- if( array10[4]->set[0] == array10[4]->set[3] ){badone = true;}
- if( array10[4]->set[0] == array10[4]->set[4] ){badone = true;}
- if( array10[4]->set[0] == array10[4]->set[5] ){badone = true;}
-
- // check set 5 against itself
- if( array10[5]->set[0] == 0 ){badone = true;}
- if( array10[5]->set[0] == array10[5]->set[1] ){badone = true;}
- if( array10[5]->set[0] == array10[5]->set[2] ){badone = true;}
- if( array10[5]->set[0] == array10[5]->set[3] ){badone = true;}
- if( array10[5]->set[0] == array10[5]->set[4] ){badone = true;}
- if( array10[5]->set[0] == array10[5]->set[5] ){badone = true;}
-
- // check set 6 against itself
- if( array10[6]->set[0] == 0 ){badone = true;}
- if( array10[6]->set[0] == array10[6]->set[1] ){badone = true;}
- if( array10[6]->set[0] == array10[6]->set[2] ){badone = true;}
- if( array10[6]->set[0] == array10[6]->set[3] ){badone = true;}
- if( array10[6]->set[0] == array10[6]->set[4] ){badone = true;}
- if( array10[6]->set[0] == array10[6]->set[5] ){badone = true;}
-
- // check set 7 against itself
- if( array10[7]->set[0] == 0 ){badone = true;}
- if( array10[7]->set[0] == array10[7]->set[1] ){badone = true;}
- if( array10[7]->set[0] == array10[7]->set[2] ){badone = true;}
- if( array10[7]->set[0] == array10[7]->set[3] ){badone = true;}
- if( array10[7]->set[0] == array10[7]->set[4] ){badone = true;}
- if( array10[7]->set[0] == array10[7]->set[5] ){badone = true;}
-
- // check set 0 against set 1
- for(int apass1 = 0; apass1 < 6; apass1++ )
- {
- if( array10[0]->set[0] == array10[1]->set[apass1] ){badone = true;}
- if( array10[0]->set[1] == array10[1]->set[apass1] ){badone = true;}
- if( array10[0]->set[2] == array10[1]->set[apass1] ){badone = true;}
- if( array10[0]->set[3] == array10[1]->set[apass1] ){badone = true;}
- if( array10[0]->set[4] == array10[1]->set[apass1] ){badone = true;}
- if( array10[0]->set[5] == array10[1]->set[apass1] ){badone = true;}
- }
-
- // check set 0 against set 2
- for(int apass2 = 0; apass2 < 6; apass2++ )
- {
- if( array10[0]->set[0] == array10[2]->set[apass2] ){badone = true;}
- if( array10[0]->set[1] == array10[2]->set[apass2] ){badone = true;}
- if( array10[0]->set[2] == array10[2]->set[apass2] ){badone = true;}
- if( array10[0]->set[3] == array10[2]->set[apass2] ){badone = true;}
- if( array10[0]->set[4] == array10[2]->set[apass2] ){badone = true;}
- if( array10[0]->set[5] == array10[2]->set[apass2] ){badone = true;}
- }
-
- // check set 0 against set 3
- for(int apass3 = 0; apass3 < 6; apass3++ )
- {
- if( array10[0]->set[0] == array10[3]->set[apass3] ){badone = true;}
- if( array10[0]->set[1] == array10[3]->set[apass3] ){badone = true;}
- if( array10[0]->set[2] == array10[3]->set[apass3] ){badone = true;}
- if( array10[0]->set[3] == array10[3]->set[apass3] ){badone = true;}
- if( array10[0]->set[4] == array10[3]->set[apass3] ){badone = true;}
- if( array10[0]->set[5] == array10[3]->set[apass3] ){badone = true;}
- }
-
- // check set 0 against set 4
- for(int apass4 = 0; apass4 < 6; apass4++ )
- {
- if( array10[0]->set[0] == array10[4]->set[apass4] ){badone = true;}
- if( array10[0]->set[1] == array10[4]->set[apass4] ){badone = true;}
- if( array10[0]->set[2] == array10[4]->set[apass4] ){badone = true;}
- if( array10[0]->set[3] == array10[4]->set[apass4] ){badone = true;}
- if( array10[0]->set[4] == array10[4]->set[apass4] ){badone = true;}
- if( array10[0]->set[5] == array10[4]->set[apass4] ){badone = true;}
- }
-
- // check set 0 against set 5
- for(int apass5 = 0; apass5 < 6; apass5++ )
- {
- if( array10[0]->set[0] == array10[5]->set[apass5] ){badone = true;}
- if( array10[0]->set[1] == array10[5]->set[apass5] ){badone = true;}
- if( array10[0]->set[2] == array10[5]->set[apass5] ){badone = true;}
- if( array10[0]->set[3] == array10[5]->set[apass5] ){badone = true;}
- if( array10[0]->set[4] == array10[5]->set[apass5] ){badone = true;}
- if( array10[0]->set[5] == array10[5]->set[apass5] ){badone = true;}
- }
-
- // check set 0 against set 6
- for(int apass6 = 0; apass6 < 6; apass6++ )
- {
- if( array10[0]->set[0] == array10[6]->set[apass6] ){badone = true;}
- if( array10[0]->set[1] == array10[6]->set[apass6] ){badone = true;}
- if( array10[0]->set[2] == array10[6]->set[apass6] ){badone = true;}
- if( array10[0]->set[3] == array10[6]->set[apass6] ){badone = true;}
- if( array10[0]->set[4] == array10[6]->set[apass6] ){badone = true;}
- if( array10[0]->set[5] == array10[6]->set[apass6] ){badone = true;}
- }
-
- // check set 0 against set 7
- for(int apass7 = 0; apass7 < 6; apass7++ )
- {
- if( array10[0]->set[0] == array10[1]->set[apass7] ){badone = true;}
- if( array10[0]->set[1] == array10[1]->set[apass7] ){badone = true;}
- if( array10[0]->set[2] == array10[1]->set[apass7] ){badone = true;}
- if( array10[0]->set[3] == array10[1]->set[apass7] ){badone = true;}
- if( array10[0]->set[4] == array10[1]->set[apass7] ){badone = true;}
- if( array10[0]->set[5] == array10[1]->set[apass7] ){badone = true;}
- }
-
- // check set 1 against set 2
- for(int bpass2 = 0; bpass2 < 6; bpass2++ )
- {
- if( array10[1]->set[0] == array10[2]->set[bpass2] ){badone = true;}
- if( array10[1]->set[1] == array10[2]->set[bpass2] ){badone = true;}
- if( array10[1]->set[2] == array10[2]->set[bpass2] ){badone = true;}
- if( array10[1]->set[3] == array10[2]->set[bpass2] ){badone = true;}
- if( array10[1]->set[4] == array10[2]->set[bpass2] ){badone = true;}
- if( array10[1]->set[5] == array10[2]->set[bpass2] ){badone = true;}
- }
-
- // check set 1 against set 3
- for(int bpass3 = 0; bpass3 < 6; bpass3++ )
- {
- if( array10[1]->set[0] == array10[3]->set[bpass3] ){badone = true;}
- if( array10[1]->set[1] == array10[3]->set[bpass3] ){badone = true;}
- if( array10[1]->set[2] == array10[3]->set[bpass3] ){badone = true;}
- if( array10[1]->set[3] == array10[3]->set[bpass3] ){badone = true;}
- if( array10[1]->set[4] == array10[3]->set[bpass3] ){badone = true;}
- if( array10[1]->set[5] == array10[3]->set[bpass3] ){badone = true;}
- }
-
- // check set 1 against set 4
- for(int bpass4 = 0; bpass4 < 6; bpass4++ )
- {
- if( array10[1]->set[0] == array10[4]->set[bpass4] ){badone = true;}
- if( array10[1]->set[1] == array10[4]->set[bpass4] ){badone = true;}
- if( array10[1]->set[2] == array10[4]->set[bpass4] ){badone = true;}
- if( array10[1]->set[3] == array10[4]->set[bpass4] ){badone = true;}
- if( array10[1]->set[4] == array10[4]->set[bpass4] ){badone = true;}
- if( array10[1]->set[5] == array10[4]->set[bpass4] ){badone = true;}
- }
-
- // check set 1 against set 5
- for(int bpass5 = 0; bpass5 < 6; bpass5++ )
- {
- if( array10[1]->set[0] == array10[5]->set[bpass5] ){badone = true;}
- if( array10[1]->set[1] == array10[5]->set[bpass5] ){badone = true;}
- if( array10[1]->set[2] == array10[5]->set[bpass5] ){badone = true;}
- if( array10[1]->set[3] == array10[5]->set[bpass5] ){badone = true;}
- if( array10[1]->set[4] == array10[5]->set[bpass5] ){badone = true;}
- if( array10[1]->set[5] == array10[5]->set[bpass5] ){badone = true;}
- }
-
- // check set 1 against set 6
- for(int bpass6 = 0; bpass6 < 6; bpass6++ )
- {
- if( array10[1]->set[0] == array10[6]->set[bpass6] ){badone = true;}
- if( array10[1]->set[1] == array10[6]->set[bpass6] ){badone = true;}
- if( array10[1]->set[2] == array10[6]->set[bpass6] ){badone = true;}
- if( array10[1]->set[3] == array10[6]->set[bpass6] ){badone = true;}
- if( array10[1]->set[4] == array10[6]->set[bpass6] ){badone = true;}
- if( array10[1]->set[5] == array10[6]->set[bpass6] ){badone = true;}
- }
-
- // check set 1 against set 7
- for(int bpass7 = 0; bpass7 < 6; bpass7++ )
- {
- if( array10[1]->set[0] == array10[7]->set[bpass7] ){badone = true;}
- if( array10[1]->set[1] == array10[7]->set[bpass7] ){badone = true;}
- if( array10[1]->set[2] == array10[7]->set[bpass7] ){badone = true;}
- if( array10[1]->set[3] == array10[7]->set[bpass7] ){badone = true;}
- if( array10[1]->set[4] == array10[7]->set[bpass7] ){badone = true;}
- if( array10[1]->set[5] == array10[7]->set[bpass7] ){badone = true;}
- }
-
- // check set 2 against set 3
- for(int cpass3 = 0; cpass3 < 6; cpass3++ )
- {
- if( array10[2]->set[0] == array10[3]->set[cpass3] ){badone = true;}
- if( array10[2]->set[1] == array10[3]->set[cpass3] ){badone = true;}
- if( array10[2]->set[2] == array10[3]->set[cpass3] ){badone = true;}
- if( array10[2]->set[3] == array10[3]->set[cpass3] ){badone = true;}
- if( array10[2]->set[4] == array10[3]->set[cpass3] ){badone = true;}
- if( array10[2]->set[5] == array10[3]->set[cpass3] ){badone = true;}
- }
-
- // check set 2 against set 4
- for(int cpass4 = 0; cpass4 < 6; cpass4++ )
- {
- if( array10[2]->set[0] == array10[4]->set[cpass4] ){badone = true;}
- if( array10[2]->set[1] == array10[4]->set[cpass4] ){badone = true;}
- if( array10[2]->set[2] == array10[4]->set[cpass4] ){badone = true;}
- if( array10[2]->set[3] == array10[4]->set[cpass4] ){badone = true;}
- if( array10[2]->set[4] == array10[4]->set[cpass4] ){badone = true;}
- if( array10[2]->set[5] == array10[4]->set[cpass4] ){badone = true;}
- }
-
- // check set 2 against set 5
- for(int cpass5 = 0; cpass5 < 6; cpass5++ )
- {
- if( array10[2]->set[0] == array10[5]->set[cpass5] ){badone = true;}
- if( array10[2]->set[1] == array10[5]->set[cpass5] ){badone = true;}
- if( array10[2]->set[2] == array10[5]->set[cpass5] ){badone = true;}
- if( array10[2]->set[3] == array10[5]->set[cpass5] ){badone = true;}
- if( array10[2]->set[4] == array10[5]->set[cpass5] ){badone = true;}
- if( array10[2]->set[5] == array10[5]->set[cpass5] ){badone = true;}
- }
-
- // check set 2 against set 6
- for(int cpass6 = 0; cpass6 < 6; cpass6++ )
- {
- if( array10[2]->set[0] == array10[6]->set[cpass6] ){badone = true;}
- if( array10[2]->set[1] == array10[6]->set[cpass6] ){badone = true;}
- if( array10[2]->set[2] == array10[6]->set[cpass6] ){badone = true;}
- if( array10[2]->set[3] == array10[6]->set[cpass6] ){badone = true;}
- if( array10[2]->set[4] == array10[6]->set[cpass6] ){badone = true;}
- if( array10[2]->set[5] == array10[6]->set[cpass6] ){badone = true;}
- }
-
- // check set 2 against set 7
- for(int cpass7 = 0; cpass7 < 6; cpass7++ )
- {
- if( array10[2]->set[0] == array10[7]->set[cpass7] ){badone = true;}
- if( array10[2]->set[1] == array10[7]->set[cpass7] ){badone = true;}
- if( array10[2]->set[2] == array10[7]->set[cpass7] ){badone = true;}
- if( array10[2]->set[3] == array10[7]->set[cpass7] ){badone = true;}
- if( array10[2]->set[4] == array10[7]->set[cpass7] ){badone = true;}
- if( array10[2]->set[5] == array10[7]->set[cpass7] ){badone = true;}
- }
-
- // check set 3 against set 4
- for(int dpass4 = 0; dpass4 < 6; dpass4++ )
- {
- if( array10[3]->set[0] == array10[4]->set[dpass4] ){badone = true;}
- if( array10[3]->set[1] == array10[4]->set[dpass4] ){badone = true;}
- if( array10[3]->set[2] == array10[4]->set[dpass4] ){badone = true;}
- if( array10[3]->set[3] == array10[4]->set[dpass4] ){badone = true;}
- if( array10[3]->set[4] == array10[4]->set[dpass4] ){badone = true;}
- if( array10[3]->set[5] == array10[4]->set[dpass4] ){badone = true;}
- }
-
- // check set 3 against set 5
- for(int dpass5 = 0; dpass5 < 6; dpass5++ )
- {
- if( array10[3]->set[0] == array10[5]->set[dpass5] ){badone = true;}
- if( array10[3]->set[1] == array10[5]->set[dpass5] ){badone = true;}
- if( array10[3]->set[2] == array10[5]->set[dpass5] ){badone = true;}
- if( array10[3]->set[3] == array10[5]->set[dpass5] ){badone = true;}
- if( array10[3]->set[4] == array10[5]->set[dpass5] ){badone = true;}
- if( array10[3]->set[5] == array10[5]->set[dpass5] ){badone = true;}
- }
-
- // check set 3 against set 6
- for(int dpass6 = 0; dpass6 < 6; dpass6++ )
- {
- if( array10[3]->set[0] == array10[6]->set[dpass6] ){badone = true;}
- if( array10[3]->set[1] == array10[6]->set[dpass6] ){badone = true;}
- if( array10[3]->set[2] == array10[6]->set[dpass6] ){badone = true;}
- if( array10[3]->set[3] == array10[6]->set[dpass6] ){badone = true;}
- if( array10[3]->set[4] == array10[6]->set[dpass6] ){badone = true;}
- if( array10[3]->set[5] == array10[6]->set[dpass6] ){badone = true;}
- }
-
- // check set 3 against set 7
- for(int dpass7 = 0; dpass7 < 6; dpass7++ )
- {
- if( array10[3]->set[0] == array10[7]->set[dpass7] ){badone = true;}
- if( array10[3]->set[1] == array10[7]->set[dpass7] ){badone = true;}
- if( array10[3]->set[2] == array10[7]->set[dpass7] ){badone = true;}
- if( array10[3]->set[3] == array10[7]->set[dpass7] ){badone = true;}
- if( array10[3]->set[4] == array10[7]->set[dpass7] ){badone = true;}
- if( array10[3]->set[5] == array10[7]->set[dpass7] ){badone = true;}
- }
-
- // check set 4 against set 5
- for(int epass5 = 0; epass5 < 6; epass5++ )
- {
- if( array10[4]->set[0] == array10[5]->set[epass5] ){badone = true;}
- if( array10[4]->set[1] == array10[5]->set[epass5] ){badone = true;}
- if( array10[4]->set[2] == array10[5]->set[epass5] ){badone = true;}
- if( array10[4]->set[3] == array10[5]->set[epass5] ){badone = true;}
- if( array10[4]->set[4] == array10[5]->set[epass5] ){badone = true;}
- if( array10[4]->set[5] == array10[5]->set[epass5] ){badone = true;}
- }
-
- // check set 4 against set 6
- for(int epass6 = 0; epass6 < 6; epass6++ )
- {
- if( array10[4]->set[0] == array10[6]->set[epass6] ){badone = true;}
- if( array10[4]->set[1] == array10[6]->set[epass6] ){badone = true;}
- if( array10[4]->set[2] == array10[6]->set[epass6] ){badone = true;}
- if( array10[4]->set[3] == array10[6]->set[epass6] ){badone = true;}
- if( array10[4]->set[4] == array10[6]->set[epass6] ){badone = true;}
- if( array10[4]->set[5] == array10[6]->set[epass6] ){badone = true;}
- }
-
- // check set 4 against set 7
- for(int epass7 = 0; epass7 < 6; epass7++ )
- {
- if( array10[4]->set[0] == array10[7]->set[epass7] ){badone = true;}
- if( array10[4]->set[1] == array10[7]->set[epass7] ){badone = true;}
- if( array10[4]->set[2] == array10[7]->set[epass7] ){badone = true;}
- if( array10[4]->set[3] == array10[7]->set[epass7] ){badone = true;}
- if( array10[4]->set[4] == array10[7]->set[epass7] ){badone = true;}
- if( array10[4]->set[5] == array10[7]->set[epass7] ){badone = true;}
- }
-
- // check set 5 against set 6
- for(int fpass6 = 0; fpass6 < 6; fpass6++ )
- {
- if( array10[5]->set[0] == array10[6]->set[fpass6] ){badone = true;}
- if( array10[5]->set[1] == array10[6]->set[fpass6] ){badone = true;}
- if( array10[5]->set[2] == array10[6]->set[fpass6] ){badone = true;}
- if( array10[5]->set[3] == array10[6]->set[fpass6] ){badone = true;}
- if( array10[5]->set[4] == array10[6]->set[fpass6] ){badone = true;}
- if( array10[5]->set[5] == array10[6]->set[fpass6] ){badone = true;}
- }
-
- // check set 5 against set 7
- for(int fpass7 = 0; fpass7 < 6; fpass7++ )
- {
- if( array10[5]->set[0] == array10[7]->set[fpass7] ){badone = true;}
- if( array10[5]->set[1] == array10[7]->set[fpass7] ){badone = true;}
- if( array10[5]->set[2] == array10[7]->set[fpass7] ){badone = true;}
- if( array10[5]->set[3] == array10[7]->set[fpass7] ){badone = true;}
- if( array10[5]->set[4] == array10[7]->set[fpass7] ){badone = true;}
- if( array10[5]->set[5] == array10[7]->set[fpass7] ){badone = true;}
- }
-
- // check set 6 against set 7
- for(int gpass7 = 0; gpass7 < 6; gpass7++ )
- {
- if( array10[6]->set[0] == array10[7]->set[gpass7] ){badone = true;}
- if( array10[6]->set[1] == array10[7]->set[gpass7] ){badone = true;}
- if( array10[6]->set[2] == array10[7]->set[gpass7] ){badone = true;}
- if( array10[6]->set[3] == array10[7]->set[gpass7] ){badone = true;}
- if( array10[6]->set[4] == array10[7]->set[gpass7] ){badone = true;}
- if( array10[6]->set[5] == array10[7]->set[gpass7] ){badone = true;}
- }
- }
-
- if( badone == true )
- {
- set_count = 0;
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- goto begin;
- }
-
-
- for( int index = 0; index < set_count; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( lotto_calc::check_if_good_num( (array10[index]->set[index2]), set_count ) == false )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- array10[index]->set[index2] = (1 + rand() % 51);
- index--;
- }
- }
- }
- }
-
-
-
- for( int index = 0; index < 6; index++ )
- {
- if( (lotto_calc::check_if_good_set( set_count, index )) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- goto begin;
- }
- }
-
- if( set_count < 8 )
- {
- limit = 2500;
- } else {
- limit = 250;
- }
-
- while( (lotto_calc::check_if_valid_sets( set_count ) == false) && (counter <= limit) )
- {
- counter++;
- }
- counter = 0;
-
- while( lotto_calc::verify_sets( set_count ) == false ){;}
-
- for( int index = 0; index < set_count; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( lotto_calc::check_if_good_num( (array10[index]->set[index2]), set_count ) == false )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- array10[index]->set[index2] = (1 + rand() % 51);
- index--;
- }
- }
- }
- }
-
-
-
-
-
- for( int index = 0; index < 6; index++ )
- {
- if( (lotto_calc::check_if_good_set( set_count, index )) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- goto begin;
- }
- }
-
-
-
- if( set_count < 8 )
- {
- limit = 2500;
- } else {
- limit = 250;
- }
-
- while( (lotto_calc::check_if_valid_sets( set_count ) == false) && (counter <= limit) )
- {
- counter++;
- }
- counter = 0;
-
- while( lotto_calc::verify_sets( set_count ) == false ){;}
-
- lotto_calc::check_missing_numbers( set_count );
-
- while( lotto_calc::check_matrix( set_count ) == false ){;}
-
- if(lotto_calc::check_for_too_many( set_count ) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- while( lotto_calc::check_matrix( set_count ) == false ){;}
- }
-
- for( int ant = 0; ant < (set_count - 1); ant++ )
- {
- for( int ant2 = (ant + 1); ant2 < set_count; ant2++ )
- {
- if( ant != ant2 )
- {
- if( array10[ant]->set[0] == array10[ant2]->set[0] )
- {
- lotto_calc::lotto_calc::reset_last_hot_pair( set_count );
- set_count--;
- goto begin;
- }
- }
- }
- }
-
- if( lotto_calc::recheck_sets( set_count ) == false )
- {
- set_count = 0;
- been_here_done_that = 0;
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- goto begin;
- }
-
- if( (lotto_calc::check_against_database( set_count )) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- goto begin;
- }
-
- for( int index = 0; index < 6; index++ )
- {
- if( (lotto_calc::check_if_good_set( set_count, index )) == false )
- {
- lotto_calc::reset_last_hot_pair( set_count );
- goto begin;
- }
- }
-
- if( set_count == (MAX_GEN - 1) )
- {
- if( (lotto_calc::is_funky( set_count )) == true )
- {
- set_count = 0;
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- goto begin;
- }
- }
-
- for( int ant = 0; ant < (set_count - 1); ant++ )
- {
- for( int ant2 = (ant + 1); ant2 < set_count; ant2++ )
- {
- if( ant != ant2 )
- {
- if( array10[ant]->set[0] == array10[ant2]->set[0] )
- {
- lotto_calc::lotto_calc::reset_last_hot_pair( set_count );
- set_count--;
- goto begin;
- }
- }
- }
- }
-
-
- if( set_count <= 8 )
- {
- for( int test = 0; test < (set_count - 1); test++ )
- {
- for( int test2 = (test + 1); test < set_count; test++ )
- {
- for( int test3 = 0; test3 < 5; test3++ )
- {
- for( int test4 = ( test3 + 1 ); test4 < 6; test4++ )
- {
- if( array10[test]->set[test3] == array10[test2]->set[test4] )
- {
- set_count = 0;
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- goto begin;
- }
- }
- }
- }
- }
- }
-
- for( int pas = 0; pas < set_count; pas++ )
- {
- for( int pas2 = 0; pas2 < 6; pas2++ )
- {
- if( array10[pas]->set[pas2] == 0 )
- {
- set_count = 0;
- for( int doit = 0; doit < 10; doit++ )
- {
- ten_hot_pairs[doit][2] = 0;
- }
- for( int index = 0; index < num_of_pairs; index++ )
- {
- thePair[index]->used = false;
- }
- goto begin;
- }
- }
- }
-
- if( set_count == 9 )
- {
- while( (lotto_calc::check_last_two_lows()) == false ){;}
- }
-
- // *WHEW* we made it this far ... must be a good one!
-
- lotto_calc::bubble_sort_sets( set_count );
- lotto_calc::get_calc_stats( set_count );
- set_count++;
-
- for( int pass = 0; pass < set_count; pass++ )
- {
- lotto_calc::bubble_sort_sets( pass );
- lotto_calc::get_calc_stats( pass );
- }
-
-
- } while( (set_count < MAX_GEN) );
-
- // getting ready to exit
- // make sure we have all the stats and clean up and get out
- for( int pass = 0; pass < set_count; pass++ )
- {
- lotto_calc::bubble_sort_sets( pass );
- lotto_calc::get_calc_stats( pass );
- }
- lotto_calc::delete_pair_structs();
- lotto_calc::clear_records();
- return true;
- }
-
- void lotto_calc::clear_stats( int theArray )
- {
- array10[theArray]->reds = 0;
- array10[theArray]->whites = 0;
- array10[theArray]->blues = 0;
- array10[theArray]->evens = 0;
- array10[theArray]->odds = 0;
- }
-
- bool lotto_calc::get_a_hot_pair( int count )
- {
- int guess = 0;
- int bail_out = 0;
- bool is_good = false;
-
-
- // try to get one of the best pairs
- do {
- guess = (1 + rand() % 10);
- bail_out++;
-
- if( ten_hot_pairs[(guess - 1)][2] == 1 )
- {
- is_good = false;
- }
- if( ten_hot_pairs[(guess - 1)][2] == 0 )
- {
- is_good = true;
- array10[count]->set[0] = ten_hot_pairs[(guess - 1)][0];
- array10[count]->set[1] = ten_hot_pairs[(guess - 1)][1];
- array10[count]->protect[0] = 1;
- array10[count]->protect[1] = 1;
- ten_hot_pairs[(guess - 1)][2] = 1; // "used"
- last_hot_pair = (guess - 1);
- return true;
- }
- } while( (is_good == false) && (bail_out <= 2500) );
-
-
- // if not ... then reset bail_out and just get a pair
- bail_out = 0;
-
- do {
- guess = (1 + rand() % (num_of_pairs - 1));
- bail_out++;
- if( bail_out > 5000 )
- {
- return false;
- }
- } while( thePair[guess]->used == true );
-
- thePair[guess]->used = true;
- array10[count]->set[0] = thePair[guess]->PAIR_1;
- array10[count]->protect[0] = 1;
- array10[count]->set[1] = thePair[guess]->PAIR_2;
- array10[count]->protect[1] = 1;
- return true;
- }
-
- void lotto_calc::reset_last_hot_pair( int count )
- {
- array10[count]->set[0] = 0;
- array10[count]->set[1] = 0;
- array10[count]->protect[0] = 0;
- array10[count]->protect[1] = 0;
- ten_hot_pairs[last_hot_pair][2] = 0; // "not used"
- last_hot_pair = NULL;
- return;
- }
-
- void lotto_calc::clear_array10( int arrayNum )
- {
- // fill everything with nulls to help avoid garbage input
- for( int index2 = 0; index2 < 6; index2++ )
- {
- array10[arrayNum]->set[index2] = NULL;
- array10[arrayNum]->protect[index2] = NULL;
- array10[arrayNum]->distrib[index2] = NULL;
- }
- array10[arrayNum]->reds = NULL;
- array10[arrayNum]->whites = NULL;
- array10[arrayNum]->blues = NULL;
- array10[arrayNum]->evens = NULL;
- array10[arrayNum]->odds = NULL;
- return;
- }
-
- void lotto_calc::get_calc_stats( int count )
- {
- lotto_calc::clear_stats( count );
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( array10[count]->set[index2] == 0 )
- {
- break;
- }
- if( (lotto_calc::is_red( array10[count]->set[index2] )) == true )
- {
- array10[count]->reds += 1;
- }
- if( (lotto_calc::is_white( array10[count]->set[index2] )) == true )
- {
- array10[count]->whites += 1;
- }
- if( (lotto_calc::is_blue( array10[count]->set[index2] )) == true )
- {
- array10[count]->blues += 1;
- }
- if( (lotto_calc::is_odd( array10[count]->set[index2] )) == true )
- {
- array10[count]->odds += 1;
- }
- if( (lotto_calc::is_even( array10[count]->set[index2] )) == true )
- {
- array10[count]->evens += 1;
- }
- }
- for( int index3 = 0; index3 < 51; index3++ )
- {
- for( int index4 = 0; index4 < 6; index4++ )
- {
- array10[count]->distrib[index4] = zeros[(array10[count]->set[index4])];
- }
- }
- return;
- }
-
-
-
- bool lotto_calc::is_red( int check )
- {
- if( (check > 0) && (check < 18) )
- {
- return true;
- } else {
- return false;
- }
- }
-
- bool lotto_calc::is_white( int check )
- {
- if( (check > 17) && (check < 35) )
- {
- return true;
- } else {
- return false;
- }
- }
-
- bool lotto_calc::is_blue( int check )
- {
- if( (check > 34) && (check < 52) )
- {
- return true;
- } else {
- return false;
- }
- }
-
- bool lotto_calc::is_odd( int check )
- {
- if( (check % 2) != 0 )
- {
- return true;
- } else {
- return false;
- }
- }
-
- bool lotto_calc::is_even( int check )
- {
- if( (check % 2) == 0 )
- {
- return true;
- } else {
- return false;
- }
- }
-
- bool lotto_calc::check_against_database( int arrayNum )
- {
- int match_count = 0;
-
- for( int index = 0; index < (number_of_records - 1); index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- if( array10[arrayNum]->set[index2] == record[index]->set[index2] )
- {
- match_count++;
- }
- }
- }
-
- if( match_count == 6 )
- {
- return false;
- } else {
- return true;
- }
- }
-
- bool lotto_calc::is_funky( int count )
- {
- int limit = 0;
- limit = (MAX_GEN / 3);
-
- int red = 0;
- int white = 0;
- int blue = 0;
- int even = 0;
- int odd = 0;
-
- lotto_calc::get_calc_stats( count );
-
- for( int index = 0; index < count; index++ )
- {
- if( array10[index]->reds > 3 )
- {
- red++;
- }
- if( array10[index]->whites > 3 )
- {
- white++;
- }
- if( array10[index]->blues > 3 )
- {
- blue ++;
- }
- if( array10[index]->evens > 3 )
- {
- even++;
- }
- if( array10[index]->odds > 3 )
- {
- odd++;
- }
- }
-
- if( red > limit ) return true;
- if( white > limit ) return true;
- if( blue > limit ) return true;
- if( odd > limit ) return true;
- if( even > limit ) return true;
-
- return false;
- }
-
- bool lotto_calc::check_if_valid_sets( int arrayNum )
- {
- if( arrayNum == 0 )
- {
- return true;
- }
-
- for( int index = 0; index < arrayNum; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- for( int index3 = 0; index3 <= arrayNum; index3++ )
- {
- for( int index4 = 0; index4 < 6; index4++ )
- {
- if( index == index3 )
- {
- if( (index != index3) && (index2 != index4) )
- {
- if( array10[index]->set[index2] == array10[index3]->set[index4] )
- {
- if( index < 8 )
- {
- if( array10[index]->protect == 0 )
- {
- array10[index]->set[index2] = (1 + rand() % 51);
- } else if( array10[index3]->protect[index4] == 0 )
- {
- array10[index3]->set[index4] = (1 + rand() % 51);
- } else {
- array10[index]->set[index2] = (1 + rand() % 51 );
- array10[index]->protect[index2] = 0;
- }
- return false;
- }
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
-
- void lotto_calc::check_missing_numbers( int arrayNum )
- {
- int eight_count = 0;
- int nine_count = 0;
- int index3 = 0;
- int index4 = 0;
- int num_check[52];
- int guess = 0;
-
- for( int pass = 0; pass < 52; pass++ )
- {
- num_check[pass] = 0;
- }
-
- if( arrayNum >= 9 )
- {
- for( int index = 0; index < 8; index++ )
- {
- for( int index5 = 0; index5 < 6; index5++ )
- {
- num_check[(array10[index]->set[index5])]++;
- }
- }
-
- do {
- guess = (1 + rand() % 51);
-
- if( num_check[guess] == 0 )
- {
- array10[8]->set[eight_count] = guess;
- array10[8]->protect[eight_count] = 0;
- num_check[guess] = 1;
- eight_count++;
- }
- if( num_check[guess] > 0 )
- {
- index3++;
- }
- } while( (index3 < 51) && (eight_count < 6) );
-
- do {
- guess = (1 + rand() % 51);
-
- if( num_check[guess] == 0 )
- {
- array10[9]->set[eight_count] = guess;
- array10[8]->protect[eight_count] = 0;
- num_check[guess] = 1;
- eight_count++;
- }
- if( num_check[guess] > 0 )
- {
- index4++;
- }
- } while( (index4 < 51) && (nine_count < 6) );
- }
-
- }
-
- bool lotto_calc::check_matrix( int arrayNum )
- {
- for( int index = 0; index < arrayNum; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- for( int index3 = 0; index3 < arrayNum; index3++ )
- {
- for( int index4 = 0; index4 < 6; index4++ )
- {
- if( index != index3 )
- {
- if( array10[index]->set[index2] == array10[index3]->set[index4] )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- if( array10[index]->set[index2] < 25 )
- {
- do {
- array10[index]->set[index2] = ( 1 + rand() % 51 );
- } while( (array10[index]->set[index2] < 25) ||
- (array10[index]->set[index2] > 51) );
- return false;
- } else {
- do {
- array10[index]->set[index2] = ( 1 + rand() % 51 );
- } while( (array10[index]->set[index2] > 25) ||
- (array10[index]->set[index2] < 1 ) );
- return false;
- }
- }
- }
- }
- if( index == index3 )
- {
- if( index2 != index4 )
- {
- if( array10[index]->set[index2] == array10[index3]->set[index4] )
- {
- if( array10[index]->protect[index2] == 0 )
- {
- if( array10[index]->set[index2] < 25 )
- {
- do {
- array10[index]->set[index2] = ( 1 + rand() % 51 );
- } while( (array10[index]->set[index2] < 25) ||
- (array10[index]->set[index2] > 51) );
- return false;
- } else {
- do {
- array10[index]->set[index2] = ( 1 + rand() % 51 );
- } while( (array10[index]->set[index2] > 25) ||
- (array10[index]->set[index2] < 1 ) );
- return false;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return true;
- }
-
- bool lotto_calc::recheck_sets( int arrayNum )
- {
- int checker[51];
- static int been_here;
-
- if( arrayNum < 9 )
- {
- been_here = 0;
- }
-
- if( been_here >= 1000 )
- {
- return true;
- }
-
- if( arrayNum >= 9 )
- {
- been_here++;
- for( int pass = 0; pass < arrayNum; pass++ )
- {
- for( int pass2 = 0; pass2 < 6; pass2++ )
- {
- checker[(array10[pass]->set[pass2])]++;
- }
- }
- for( int pass3 = 0; pass3 < 51; pass3++ )
- {
- if( checker[pass3] == 0 )
- {
- return false;
- }
- }
- }
- return true;
- }
-
-
- bool lotto_calc::check_for_too_many( int arrayNum )
- {
- int the_check[51] = {NULL};
- static int done_that;
- static int array_check[10][6];
-
- if( arrayNum < 9 )
- {
- done_that = 0;
- for( int pass = 0; pass < 10; pass++ )
- {
- for( int pass2 = 0; pass2 < 6; pass2++ )
- {
- array_check[pass][pass2] = 0;
- }
- }
- return true;
- }
-
-
- if( done_that >= 4 ) // allow 4 protected numbers to be changed
- {
- return true;
- }
-
- for( int index = 0; index < arrayNum; index++ )
- {
- for( int index2 = 0; index2 < 6; index2++ )
- {
- the_check[(array10[index]->set[index2])]++;
- }
- }
- for( int index3 = 0; index3 < 51; index3++ )
- {
- if( the_check[index3] > 2 )
- {
- for( int index4 = arrayNum; index4 <= 0; index4-- )
- {
- for( int index5 = 0; index5 < 6; index5++ )
- {
- if( array_check[index4][index5] != 1 )
- {
- if( array10[index4]->protect[index5] == 1 )
- {
- array10[index4]->protect[index5] = 0;
- array_check[index4][index5] = 1;
- done_that++;
- return false;
- }
- }
- }
- }
- }
- }
- return true;
- }
-
- int lotto_calc::get_rollover( void )
- {
- int total = 0;
- int average = 0;
- int hits = 0;
-
- lotto_calc::read_file();
- for( int pass = 1; pass < number_of_records; pass++ )
- {
- if( record[0]->set[0] == record[pass]->set[0] )
- {
- if( record[0]->set[0] < record[pass - 1]->set[0] )
- {
- total += ( (record[pass - 1]->set[0]) - (record[0]->set[0]) );
- hits++;
- } else {
- total += ( (record[0]->set[0]) - (record[pass - 1]->set[0]) );
- hits++;
- }
- }
- }
- lotto_calc::clear_records();
-
- average = ( total / hits );
- return( average );
- }
-
- bool lotto_calc::predict_set( void )
- {
- int hold = 0;
- int hits_1 = 0;
- int temp_1 = 0;
- int hits_2 = 0;
- int temp_2 = 0;
- int hits_3 = 0;
- int temp_3 = 0;
- int red_avg = 0;
- int white_avg = 0;
- int blue_avg = 0;
- int count = 0;
-
- for( int n = 0; n < 6; n++ )
- {
- p_set->the_set[n] = 0;
- }
-
- p_set->the_set[0] = lotto_calc::get_rollover();
-
- lotto_calc::read_file();
-
- // find out how many reds, whites & blues we need
- for( int pas1 = 1; pas1 < number_of_records; pas1++ )
- {
- if( record[0]->reds == record[pas1]->reds )
- {
- temp_1 += record[pas1 - 1]->reds;
- hits_1++;
- }
- }
- red_avg = ( temp_1 / hits_1 );
-
- for( int pas3 = 1; pas3 < number_of_records; pas3++ )
- {
- if( record[0]->whites == record[pas3]->whites )
- {
- temp_2 += record[pas3 - 1]->whites;
- hits_2++;
- }
- }
- white_avg = ( temp_2 / hits_2 );
-
- for( int pas5 = 1; pas5 < number_of_records; pas5++ )
- {
- if( record[0]->blues == record[pas5]->blues )
- {
- temp_3 += record[pas5 - 1]->blues;
- hits_3++;
- }
- }
- blue_avg = ( temp_3 / hits_3 );
-
- while( (red_avg + white_avg + blue_avg) > 6 )
- {
- int choose = 0;
- choose = (1 + rand() % 3);
- switch( choose )
- {
- case 1:
- {
- red_avg--;
- break;
- }
- case 2:
- {
- white_avg--;
- break;
- }
- case 3:
- {
- blue_avg--;
- break;
- }
- default:
- {
- break;
- }
- }
- }
-
- while( (red_avg + white_avg + blue_avg) < 6 )
- {
- int choose = 0;
- choose = (1 + rand() % 3);
- switch( choose )
- {
- case 1:
- {
- red_avg++;
- break;
- }
- case 2:
- {
- white_avg++;
- break;
- }
- case 3:
- {
- blue_avg++;
- break;
- }
- default:
- {
- break;
- }
- }
- }
-
- if( (lotto_calc::is_red( p_set->the_set[0] )) == true )
- {
- red_avg--;
- }
- if( (lotto_calc::is_blue( p_set->the_set[0] )) == true )
- {
- blue_avg--;
- }
- if( (lotto_calc::is_white( p_set->the_set[0] )) == true )
- {
- white_avg--;
- }
-
- count = 1; // we already have p_set->the_set[0]
-
- // get random reds, whites & blues to fill needed amounts
- for( int pas2 = 0; pas2 < red_avg; pas2++ )
- {
- if( lotto_calc::is_red( p_set->the_set[0] ) == true )
- {
- pas2++;
- }
- while( (lotto_calc::is_red( p_set->the_set[count] = (1 + rand() % 51))) != true
- || p_set->the_set[count] < p_set->the_set[0]){;}
- count++;
- }
- for( int pas4 = 0; pas4 < white_avg; pas4++ )
- {
- if( lotto_calc::is_white( p_set->the_set[0] ) == true )
- {
- pas4++;
- }
- while( (lotto_calc::is_white( p_set->the_set[count] = (1 + rand() % 51))) != true
- || p_set->the_set[count] < p_set->the_set[0]){;}
- count++;
- }
- for( int pas6 = 0; pas6 < blue_avg; pas6++ )
- {
- if( lotto_calc::is_blue( p_set->the_set[0] ) == true )
- {
- pas6++;
- }
- while( (lotto_calc::is_blue( p_set->the_set[count] = (1 + rand() % 51))) != true
- || p_set->the_set[count] < p_set->the_set[0]){;}
- count++;
- }
-
- for( int index = 0; index < 6; index++ )
- {
- for( int index2 = (index + 1); index2 < 6; index2++ )
- {
- if( p_set->the_set[index] == 0 )
- {
- return( false );
- }
- if( p_set->the_set[index] == p_set->the_set[index2] )
- {
- return( false );
- }
- }
- }
-
- for( int check = 0; check < 6; check++ )
- {
- if( p_set->the_set[0] == 0 )
- {
- return false;
- }
- }
-
- for( int pass = 1; pass <= (6 - 1); pass++ )
- {
- for( int pass2 = 0; pass2 <= (6 - 2); pass2++ )
- {
- if( p_set->the_set[pass2] > p_set->the_set[pass2 + 1] )
- {
- hold = p_set->the_set[pass2];
- p_set->the_set[pass2] = p_set->the_set[pass2 + 1];
- p_set->the_set[pass2 + 1] = hold;
- }
- }
- }
-
- return ( true );
- }
-
- bool lotto_calc::check_last_two_lows( void )
- {
- for( int la = 0; la < 7; la++ )
- {
- for( int la2 = 0; la2 < 6; la2++ )
- {
- if( array10[9]->set[0] == array10[la]->set[la2] )
- {
- do {
- array10[9]->set[0] = (1 + rand() % 25);
- } while( array10[9]->set[0] == array10[la]->set[la2] );
- return false;
- }
-
- if( array10[8]->set[0] == array10[la]->set[la2] )
- {
- do {
- array10[8]->set[0] = (1 + rand() % 51);
- } while( array10[8]->set[0] == array10[la]->set[la2] );
- return false;
- }
- }
- }
- return true;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-